package wiki.zimo.domain;

import wiki.zimo.annotation.Column;
import wiki.zimo.annotation.ID;
import wiki.zimo.annotation.Table;

import java.sql.Timestamp;
import java.util.List;
import java.util.Objects;

/**
 * @auther: 子墨
 * @datetime: 2018/11/7 12:33
 * @describe: 订单实体类
 */
@Table(value = "`order`")
public class Order {

    @ID(value = "oid")
    private String oid;

    private List<Orderitem> orderItems;// 订单项集

    @Column(value = "uid")
    private String uid;

    private User user;

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Column(value = "ordertime")
    private java.sql.Timestamp ordertime;

    @Column(value = "total")
    private double total;

    @Column(value = "state")
    private long state;

    @Column(value = "address")
    private String address;

    @Column(value = "name")
    private String name;

    @Column(value = "telephone")
    private String telephone;

    public List<Orderitem> getOrderItems() {
        return orderItems;
    }

    public void setOrderItems(List<Orderitem> orderItems) {
        this.orderItems = orderItems;
    }

    public String getOid() {
        return oid;
    }

    public void setOid(String oid) {
        this.oid = oid;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public Timestamp getOrdertime() {
        return ordertime;
    }

    public void setOrdertime(Timestamp ordertime) {
        this.ordertime = ordertime;
    }

    public double getTotal() {
        return total;
    }

    public void setTotal(double total) {
        this.total = total;
    }

    public long getState() {
        return state;
    }

    public void setState(long state) {
        this.state = state;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Order order = (Order) o;
        return Double.compare(order.total, total) == 0 &&
                state == order.state &&
                Objects.equals(oid, order.oid) &&
                Objects.equals(orderItems, order.orderItems) &&
                Objects.equals(uid, order.uid) &&
                Objects.equals(ordertime, order.ordertime) &&
                Objects.equals(address, order.address) &&
                Objects.equals(name, order.name) &&
                Objects.equals(telephone, order.telephone);
    }

    @Override
    public int hashCode() {

        return Objects.hash(oid, orderItems, uid, ordertime, total, state, address, name, telephone);
    }

    @Override
    public String toString() {
        return "Order{" +
                "oid='" + oid + '\'' +
                ", orderItems=" + orderItems +
                ", uid='" + uid + '\'' +
                ", ordertime=" + ordertime +
                ", total=" + total +
                ", state=" + state +
                ", address='" + address + '\'' +
                ", name='" + name + '\'' +
                ", telephone='" + telephone + '\'' +
                '}';
    }
}
